<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    // 1、字面量方式创建对象
    var obj = {}
    console.log(obj)

    var student = {
      name: 'zhangsan',
      age: 23,
      study: function () {
        console.log(this.name + '在学习')
      }
    }
    //给对象添加其他成员
    student.gender = '男'
    student.show = function () {
      console.log(this.name + ': show()')
    }
    student.show()
    console.log(student)

    //2.构造函数的方式创建对象
    function Animal() {
      this.name = 'kitty'
      this.age = 23
      this.run = function () {
        console.log(this.name + ' 正在跑步')
      }
    }
    var cat = new Animal()
    cat.run()
  </script>
</body>

</html>